﻿<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#x00A0;">
]>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxml="urn:schemas-microsoft-com:xslt"
  xmlns:site.library="urn:site.library"
  xmlns:site.defaults="urn:site.defaults"
  xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"   xmlns:examine="urn:examine"
  exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets   examine site.library site.defaults">

  <xsl:output method="xml" omit-xml-declaration="yes"/>

  <xsl:param name="currentPage" />

  <xsl:variable name="macroPage" select="umbraco.library:GetXmlNodeById(string(/macro/macroPage))" />
  <!--settings-->
  <xsl:variable name="defaultImageUrl" select="site.library:GetImageUrl($macroPage/image,'/images/default-top-image.jpg')"/>
  <!--end settings-->
  <xsl:variable name="SiteInfo" select="site.library:PageSite($currentPage/@id)"/>
  <xsl:variable name="Site" select="umbraco.library:GetXmlNodeById($SiteInfo/node/@id)"/>

  <xsl:variable name="DefaultPage" select="site.defaults:DefaultPage($currentPage/@id)"/>

  <xsl:variable name="selPages" select="$currentPage/ancestor-or-self::*"/>
  <xsl:variable name="imageId" select="site.library:ShortIf(string-length($currentPage/image)>0, $currentPage/image, $DefaultPage/image)"/>


  <xsl:template match="/">
    <div class="page-image-holder">
      <div class="wrapper">
        <img alt="{$currentPage/@nodeName}" src="{site.library:GetImageUrl($imageId,$defaultImageUrl)}" />
      </div>
      <!--<script type="text/javascript"> initPageTitleImage(); </script>-->
      <xsl:variable name="IntroText" select="site.library:ShortIf(string-length($currentPage/introText)>0,$currentPage/introText,$DefaultPage/introText)"/>
      <xsl:variable name="IntroThumbnailUrl" select="site.library:GetImageUrl($DefaultPage/thumbnail,'')"/>
      <xsl:if test="string-length($IntroText)>0 or string-length($IntroThumbnailUrl)>0">
        <div class="page-image-title">
          <table>
            <tr>
              <td class="icon-holder">
                <xsl:choose>
                  <xsl:when test="string-length($IntroThumbnailUrl) > 0">
                    <img src="{$IntroThumbnailUrl}" alt="thumbnail" />
                  </xsl:when>
                  <xsl:otherwise>
                    <!--nothumbnail.png-->
                  </xsl:otherwise>
                </xsl:choose>
              </td>
              <td class="title">
                <h2>
                  <xsl:value-of disable-output-escaping="yes" select="$IntroText"/>
                </h2>
              </td>
            </tr>
          </table>
        </div>
      </xsl:if>
    </div>
  </xsl:template>
</xsl:stylesheet>